package com.wenhai.spring.dependency.injection;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;

/**
 * @Author:wenhai
 * @Description: {@link Value}注入示例
 * @Date:2020/3/30
 */
public class ValueAnnotationDependencyInjectionDemo {
    @Value("${usr.name:文海}")
    private String username;

    public static void main(String[] args) {
        AnnotationConfigApplicationContext applicationContext = new AnnotationConfigApplicationContext();
        applicationContext.register(ValueAnnotationDependencyInjectionDemo.class);
        applicationContext.refresh();
        ValueAnnotationDependencyInjectionDemo bean = applicationContext.getBean(ValueAnnotationDependencyInjectionDemo.class);
        System.out.println(bean.username);
        applicationContext.close();
    }
}
